package com.redrose.rxandroiddemo.database;

import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.redrose.rxandroiddemo.util.ContextUtil;

public class RoomDataBaseUtil {
    private RoomDataBaseUtil() {
        myRoomDataBase = Room.databaseBuilder(ContextUtil.getInstance().getContext(), MyRoomDataBase.class, "women_database")
                .allowMainThreadQueries()
                .build();
    }

    private final MyRoomDataBase myRoomDataBase;

    private static RoomDataBaseUtil mInstance;

    public static RoomDataBaseUtil getInstance() {
        if (mInstance == null) {
            synchronized (RoomDataBaseUtil.class) {
                if (mInstance == null) {
                    mInstance = new RoomDataBaseUtil();
                }
            }
        }
        return mInstance;
    }

    public MyRoomDataBase getMyRoomDataBase() {
        return myRoomDataBase;
    }

    public WomenDao getWomenDao() {
        return myRoomDataBase.getWomenDao();
    }
}
